<template>
  <el-container style="border: 1px solid #eee">
    <el-aside width="200px"
              style="background-color: rgb(238, 241, 246)">
      <el-menu>
        <el-submenu index="1">
          <template slot="title"><i class="el-icon-message"></i>
            <router-link to="/menu/echarts"
                         tag="span">首页</router-link>
          </template>
        </el-submenu>
        <el-submenu index="2">
          <template slot="title"><i class="el-icon-menu"></i>
            <router-link to="" tag="span">仓库管理</router-link>
          </template>
          <el-menu-item index="2-1">
            <template slot="title">
              <router-link to="/menu/rk_manage"
                           tag="span">入库管理</router-link>
            </template>
          </el-menu-item>
          <el-menu-item index="2-2">
            <template slot="title"><router-link to="/menu/ck_manage" tag="span">出库管理</router-link></template>
            
          </el-menu-item>
          <el-menu-item index="2-3">
            <template slot="title">
              <router-link to="/menu/repository_manage"
                           tag="span">库存管理</router-link>
            </template>
          </el-menu-item>
          <el-submenu index="2-4">
            <template slot="title">调拨管理</template>
            <el-menu-item index="2-4-1">新增调拨单</el-menu-item>
            <el-menu-item index="2-4-2">调拨详情</el-menu-item>
          </el-submenu>
          <el-submenu index="2-5">
            <template slot="title">分称管理</template>
            <el-menu-item index="2-5-1">新增分称单</el-menu-item>
            <el-menu-item index="2-5-2">分称详情</el-menu-item>
          </el-submenu>
          <el-submenu index="2-6">
            <template slot="title">货品转换</template>
            <el-menu-item index="2-6-1">单品转通品</el-menu-item>
            <el-menu-item index="2-6-2">转换详情</el-menu-item>
          </el-submenu>
          <el-menu-item index="2-7">
            <template slot="title">
              <router-link to="/menu/repository_syslog" tag="span">仓库日志</router-link>
            </template>
          </el-menu-item>
        </el-submenu>

        <!-- 采购管理模块 -->
        <el-submenu index="3">
          <template slot="title"><i class="el-icon-shopping-cart-2"></i>采购管理</template>
          <el-submenu index="3-1">
            <template slot="title">
              <router-link to="/menu/demandList"
                           tag="span">需求单</router-link>
            </template>

            <router-link to="/menu/newDemandOrder"
                         tag="span">
              <el-menu-item index="3-1-1">
                新增需求单
              </el-menu-item>
            </router-link>

            <router-link to="/menu/editDemandList"
                         tag="span">
              <el-menu-item index="3-1-2">
                编辑需求单
              </el-menu-item>
            </router-link>

            <router-link to="/menu/demandOrderDetails"
                         tag="span">
              <el-menu-item index="3-1-3">
                需求单详情
              </el-menu-item>
            </router-link>
          </el-submenu>

          <el-submenu index="3-2">
            <template slot="title">
              <router-link to="/menu/distributionDemandOrder"
                           tag="span">分配需求单</router-link>
            </template>

            <router-link to="/menu/operationDemandSheet"
                         tag="span">
              <el-menu-item index="3-2-1">需求单分配</el-menu-item>
            </router-link>

            <router-link to="/menu/distributionDemandOrderDetails"
                         tag="span">
              <el-menu-item index="3-2-2">分配需求单详情</el-menu-item>
            </router-link>
          </el-submenu>

          <el-submenu index="3-3">
            <template slot="title">
              <router-link to="/menu/purchaseOrder"
                           tag="span">采购单</router-link>
            </template>

            <router-link to="/menu/newPurchaseOrder"
                         tag="span">
              <el-menu-item index="3-3-1">新增采购单</el-menu-item>
            </router-link>

            <router-link to="/menu/editPurchaseOrder"
                         tag="span">
              <el-menu-item index="3-3-2">编辑采购单</el-menu-item>
            </router-link>

            <router-link to="/menu/purchaseOrderDetails"
                         tag="span">
              <el-menu-item index="3-3-3">采购单详情</el-menu-item>
            </router-link>
          </el-submenu>

        </el-submenu>

        <el-submenu index="4">
          <template slot="title"><i class="el-icon-setting"></i>销售管理</template>
          <el-submenu index="4-1">
            <template slot="title">
              <router-link to="/menu/selectgoodslist"
                           tag="span">选货单管理</router-link>
            </template>
            <router-link to="/menu/addselectgoodsorder"
                         tag="span">
              <el-menu-item index="4-1-1">新增选货单</el-menu-item>
            </router-link>
            <router-link to="/menu/selectgoodsdetail"
                         tag="span">
              <el-menu-item index="4-1-2">选货单详情</el-menu-item>
            </router-link>
          </el-submenu>

          <el-submenu index="4-2">
            <template slot="title">
              <router-link to="/menu/packingorder"
                           tag="span">打包单管理</router-link>
            </template>
            <el-menu-item index="4-2-1">新增打包单</el-menu-item>
            <router-link to="/menu/packingorderdetailbyupstream"
                         tag="span">
              <el-menu-item index="4-2-2">打包单详情</el-menu-item>
            </router-link>

          </el-submenu>

          <el-submenu index="4-3">
            <template slot="title">
              <router-link to="/menu/finalstatement"
                           tag="span">
                结算单管理
              </router-link>
            </template>
            <router-link to="/menu/finalstatementbygoods" tag="span">
                <el-menu-item index="4-3-1">产品结算</el-menu-item>
            </router-link>

            <router-link to="/menu/finalstatementbyupstreamorder" tag="span">
              <el-menu-item index="4-3-2">上游单结算</el-menu-item>
            </router-link>
          </el-submenu>

        </el-submenu>

        <el-submenu index="9">
          <template slot="title"><i class="el-icon-message"></i>合作关系</template>
          <router-link to="/menu/custommanage"
                       tag="span">
            <el-menu-item index="9-1">客户管理</el-menu-item>
          </router-link>
          <router-link to="/menu/suppliermanage"
                       tag="span">
            <el-menu-item index="9-2">供应商管理</el-menu-item>
          </router-link>
          <router-link to="/menu/salesermanage"
                       tag="span">
            <el-menu-item index="9-3">业务员管理</el-menu-item>
          </router-link>
          <router-link to="/menu/focusbusiness"
                       tag="span">
            <el-menu-item index="9-4">关注友商管理</el-menu-item>
          </router-link>
        </el-submenu>
        <el-submenu index="5">
          <template slot="title"><i class="el-icon-setting"></i>财务管理</template>
          <el-menu-item index="5-1">
            <router-link to="/menu/recharge_record"
                         tag="span">客户充值管理</router-link>
          </el-menu-item>
          <el-menu-item index="5-2">
            <router-link to="/menu/customer_account"
                         tag="span">客户账户管理</router-link>
          </el-menu-item>
        </el-submenu>
        <el-submenu index="6">
          <template slot="title"><i class="el-icon-setting"></i>商品管理</template>
          <el-menu-item index="6-1">
            <router-link to="/menu/product"
                         tag="span">产品管理</router-link>
          </el-menu-item>
          <el-menu-item index="6-2">
            <router-link to="/menu/follow_push"
                         tag="span">产品关注</router-link>
          </el-menu-item>
          <el-menu-item index="6-3">
            <router-link to="/menu/buy_price"
                         tag="span">采购定价</router-link>
          </el-menu-item>
          <el-menu-item index="6-4">
            <router-link to="/menu/sale_price"
                         tag="span">销售定价</router-link>
          </el-menu-item>
        </el-submenu>
        <el-submenu index="8">
          <template slot="title"><i class="el-icon-setting"></i>基础数据</template>
          <el-menu-item index="8-1">
            <router-link to="/menu/area"
                         tag="span">区域管理</router-link>
          </el-menu-item>
          <el-menu-item index="8-2">
            <router-link to="/menu/goods"
                         tag="span">物料分类</router-link>
          </el-menu-item>
          <el-menu-item index="8-3">
            <router-link to="/menu/category"
                         tag="span">品类管理</router-link>
          </el-menu-item>
          <el-menu-item index="8-4">
            <router-link to="/menu/series"
                         tag="span">系列管理</router-link>
          </el-menu-item>
          <el-menu-item index="8-5">
            <router-link to="/menu/product_line"
                         tag="span">产品线管理</router-link>
          </el-menu-item>
        </el-submenu>
        <el-submenu index="7">
          <template slot="title"><i class="el-icon-setting"></i>管理系统</template>
            <el-menu-item index="7-1">
              <router-link to="/menu/users" tag="span">用户管理</router-link>
            </el-menu-item>
            <el-menu-item index="7-2">
              <router-link to="/menu/roles" tag="span">角色管理</router-link>
            </el-menu-item>
            <el-menu-item index="7-3">
              <router-link to="/menu/perms" tag="span">权限配置</router-link>
            </el-menu-item>
            <el-menu-item index="7-4">
              <router-link to="/menu/exporttask" tag="span">导出任务</router-link>
            </el-menu-item>
        </el-submenu>
        <el-submenu index="8">
          <template slot="title"><i class="el-icon-setting"></i>会员管理</template>
          <el-menu-item-group>
            <el-menu-item index="8-1">选项1</el-menu-item>
            <el-menu-item index="8-2">选项2</el-menu-item>
          </el-menu-item-group>
          <el-menu-item index="8-3">选项3</el-menu-item>
          <el-submenu index="8-4">
            <template slot="title">选项4</template>
            <el-menu-item index="8-4-1">选项4-1</el-menu-item>
          </el-submenu>
        </el-submenu>
      </el-menu>
    </el-aside>

    <el-container>
      <el-header>
        <span style="font-size: 20px">深圳猪猪侠信息有限公司</span>
        <span style="float: right">
          <el-dropdown @command="handleCommand">
            <span><i class="el-icon-setting" style="margin-right: 15px"></i>{{account}}</span>
            
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item command="a">修改密码</el-dropdown-item>
              <el-dropdown-item command="quit">退出</el-dropdown-item>
            </el-dropdown-menu>
            
          </el-dropdown>
          
        </span>
      </el-header>

      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>


<style>
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
}

.el-aside {
  color: #333;
}
</style>

<script>
export default {
  data(){
    return {
      account:this.$store.state.grades.account
    }
  },
  methods:{
    handleCommand(command) {
      //console.log(command);
      if(command == "quit"){
        //window.sessionStorage.clear();
        window.sessionStorage.removeItem("token");
        window.sessionStorage.removeItem("refreshtoken");
        console.log(window.sessionStorage.getItem("token"));
        this.$store.commit("setGrades",null);
        this.$router.push("/");
      }
    }
  }
}
</script>
